package tankgame5;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

public class HspTankGame05 extends JFrame {
    MyPanel my=null;

    public static void main(String[] args) {
         HspTankGame05 hspTankGame02 = new HspTankGame05();
    }

    public HspTankGame05()  {
        Scanner scanner = new Scanner(System.in);
        System.out.println("1：新游戏  2：继续上局游戏");
        String key = scanner.next();

        my=new MyPanel(key);

        new Thread(my).start();

        this.add(my);
        this.setSize(1000,700);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
        this.addKeyListener(my);

        //点击右上角关闭按钮，该方法会执行，程序再关闭
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.out.println("================");
                Recorder.keepRecord();
            }

        });
    }
}
